#ifndef _H_GM_DEFS_
#define _H_GM_DEFS_

#define MK_DISABLE_AUTOMUTEX

#include <middleware/gm_api/skfapi.h>

#include <middleware/apdu/apdu.lib/apdu_lib_common.h>

#define ERROR_THROW(r) {if((r) != 0) goto END_OF_FUN;}
 
#ifndef MK_DISABLE_AUTOMUTEX
	#define MK_AUTO_MUTEX MK_AUTO_MUTEX_NAME(g_szDeviceID)
#else
	#define MK_AUTO_MUTEX
#endif

#define ERROR_THROW_APDU(r)						\
		{										\
			if((r) != 0)						\
			{									\
				(r) = get_last_sw_err();		\
				goto END_OF_FUN;				\
			}									\
		}

#define DELETE_BUFFER_PTR(r) {if(r) {delete []r; r=NULL;}}

#define TRACE_ASSERT(r)								\
		{											\
			if(!(r))								\
			{										\
				lRslt = SAR_INVALIDPARAMERR;		\
				goto END_OF_FUN;					\
			}										\
		}											

#define TRACE_ASSERT_LEN(p,q)						\
		 {											\
			 if((p) < (q))							\
			 {										\
				 (p) = (q);							\
				 lRslt = SAR_BUFFER_TOO_SMALL;		\
				 goto END_OF_FUN;					\
			 }										\
			 (p) = (q);								\
		 }

//#define DEVICE_ID	"mtoken-gm"

typedef HANDLE DEV_HANDLE;

#define RSA_KEYPAIR_BITS_1024		1024
#define RSA_KEYPAIR_BITS_2048		2048

#define ECC_MODULUS_BITS_LEN		256

#define GM_CONTAINER_TYPE_ECC		2
#define GM_CONTAINER_TYPE_RSA		1

#define GM_AGREEMENT_USER_ID		"1234567812345678"
#define GM_AGREEMENT_USER_ID_LEN	16

#define FALSE 0
#define TRUE  1


#define  APP_GLOBAL_CONTAINER_NAME		{0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0x00};

#define GM_STANDARD_NEW

#endif //_H_GM_DEFS_